package com.andrew.mapper;

import com.andrew.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;


@Mapper
public interface EmpMapper {
    // 删除员工
//    @Delete("delete from emp where id = #{id}")
    public void delete(List<Integer> ids);

    //新增员工
    @Options(useGeneratedKeys = true, keyProperty = "id")// 插入成功后，将主键返回
    @Insert("insert into emp(username, name, gender, image, job, " +
            "entrydate, dept_id, create_time, update_time) values (#{username}, #{name}," +
            "#{gender}, #{image}, #{job}, #{entrydate}, #{deptId}, #{createTime}, #{updateTime})")
    public void insert(Emp emp);

    //修改员工
    @Update("update emp set username = #{username}, name = #{name}, gender = #{gender}," +
            "image = #{image}, job = #{job}, entrydate = #{entrydate}, dept_id = #{deptId}," +
            "update_time = #{updateTime} where id = #{id}")
    public void update(Emp emp);

    //根据id查询员工
    @Select("select * from emp where id = #{id}")
    public Emp getById(Integer id);

    //根据条件查询
//    @Select("select * from emp where name like concat('%',#{name}, '%') " +
//            "and gender = #{gender} " +
//            "and entrydate between #{begin} " +
//            "and #{end} order by update_time desc")
    public List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);


    public void update2(Emp emp);
}
